package org.metasketch.demo.diagrams.ATD;

import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.StrokeType;

import org.metasketch.demo.model.OrganizationalUnit;
import org.metasketch.diagram.javafx.graphics.BaseGraphic;
import org.metasketch.diagram.javafx.graphics.CustomLabel;
import org.metasketch.graphics.GraphicContainer;
import org.metasketch.model.CommonIdentified;

public class OrganizationUnitNode extends BaseGraphic {

	Rectangle rect;//

	CustomLabel label = new CustomLabel("Untitled");

	Color lineColor = Color.DARKGRAY;

	public OrganizationUnitNode() {
		super(new GraphicContainer(0, 0, 400, 200));

	}

	@Override
	protected void continueSetup() {

		setupGraphic(graphicNode.getX(), graphicNode.getY(),
				graphicNode.getWidth(), graphicNode.getHeight());

	}

	private void setupGraphic(int x, int y, int width, int height) {

		this.width = width;
		this.height = height;

		setX(x);
		setY(y);

		rect = new Rectangle(1, 1, width, height);
		rect.setStroke(lineColor);
		rect.setStrokeWidth(4);
		rect.setStrokeType(StrokeType.OUTSIDE);
		rect.setFill(Color.TRANSPARENT);

		label.setGraphic(this);
		label.setTextVerticalTop();
		label.setVerticallyCentered(false);
		label.setFieldNameEditing("name", true);

		getChildren().addAll(rect, label);
	}

	@Override
	protected void resizeGraphic() {
		rect.setWidth(width);
		rect.setHeight(height);

		label.resize();

	}

	@Override
	protected void refreshModelGraphic() {
		OrganizationalUnit role = (OrganizationalUnit) semantic;

		// label.setText(role.getName());

		label.refreshModelGraphic();
		// identifierLabel.refreshModelGraphic();

	}

	
}
